//
//  ZineViewModelVC.m
//  YZZX
//
//  Created by Easaa on 15/4/20.
//  Copyright (c) 2015年 Easaa. All rights reserved.
//

#import "ZineViewModelVC.h"
#import "ZilneView.h"


@interface ZineViewModelVC ()<HXHttpRequestDelegate,ZilneViewDelegat>
{
    NSMutableArray *        _ContactData;
    HXHttpRequest           *_httpRequest;

}

@end

@implementation ZineViewModelVC




-(id)initWithZineCateGoryData:(CategoryDataModel *)categoryModel
{

    self= [super init];
    if(self)
    {
        self.ModelData = categoryModel;
        _ContactData = [[NSMutableArray alloc]init];
        
    }
    
    return self;




}



- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
  [self RequstDataListTableview];

    
    
}
- (void)viewDidUnload
{
    [super viewDidUnload];
    _ContactData = nil;
}



-(void)RequstDataListTableview
{
    //列表请求
    NSDictionary* dicParams = [NSDictionary dictionaryWithObjectsAndKeys:
                               [XSZ_UICommon useridChangUaerdfLoginBoolString],                            @"user_id",
                               @"1",                            @"site_id",
                                self.ModelData.cate_id,         @"cate_id",
                               [NSNumber numberWithInteger:1],  @"page_no",
                               [NSNumber numberWithInteger:10], @"page_size",
                               nil];
    
    if (_httpRequest == nil)
    {
        _httpRequest = [[HXHttpRequest alloc] init];
        _httpRequest.delegate = self;
        
        
        
    }
    [_httpRequest requestForParams:dicParams andMethod:YZ_ZINE_LIST andTag:1001];//@"system.time"];//
    
    
}




#pragma mark - HXHttpRequestDelegate  代理

- (void)requestFinished:(NSString *)responseString andStatusCode:(int)statusCode andTag:(NSInteger)tag
{
    
   
    NSDictionary *dic = [[NSDictionary alloc]init];
    dic = [JsonUtil jsonToDic:responseString];
    
    if ([dic[@"data"] isEqual:[NSNull null]])
    {
        return;
    }
    
    NSString * strs = dic[@"data"];
    
    NSDictionary *dics =[JsonUtil jsonToDic:strs];
    
    NSArray *arryy =(NSArray *)dics;
    
    NSLog(@"-----------> %@",arryy);
    
    
    
    [_ContactData removeAllObjects];
    
    for (NSDictionary *dicuu in arryy)
    {
        ZilneListDataModel  *modeContact =[[ZilneListDataModel alloc]initWithDataDic:dicuu];
        [_ContactData addObject:modeContact];
    }

    
    ZilneView  *zilview =[[ZilneView alloc]initWithFrame:CGRectMake(0, 0, Dev_ScreenWidth, Dev_ScreenHeight-64-30) Data:_ContactData];
    zilview.delegaeZline =self.rootviews;
    [self.view addSubview:zilview];
    
    
}

- (void)requestFailed:(NSError *)error andTag:(NSInteger)tag
{
    
}





@end
